package game.core
{
	public class Group
	{
		public function Group()
		{
		}
		public var list:Array = [];
		public var type:int = 0;
		public var bOne:Boolean = false;//先手是否成过
		public var bTwo:Boolean = false;//后手是否成过
		public var id:int = 0;
		public var value:int = 0;//奖励
		
		public static var FANG:int = 1; //方
		public static var LA:int =2;//拉
		public static var XIE3:int = 3; //三斜
		public static var XIE4:int = 4; //四步
		public static var XIE5:int = 5; //五通
		
		public function setList(a:Array):void
		{
			this.list = a;
			for each(var p:FLPoint in a)
				p.addGroup(this);
		}
		
		public function canSucc(p:FLPoint,side:int):int
		{
			var n:int = 0;
			for(var i:int =0;i<list.length;i++)
			{
				var flp:FLPoint = list[i];
				if(flp!=p){
					if(flp.z == FLPoint.NONE)
						n++;
					else if(flp.z == side){
						
					}else{
						n+= 10;
					}
				}
			}
			return n;
		}
		
		public function checkSucc(p:FLPoint):Boolean{
			for(var i:int =0;i<list.length;i++)
			{
				var flp:FLPoint = list[i];
				if(flp!=p){
					if(flp.z != p.z)
						return false;
				}
			}
			
			if(p.z == FLPoint.ONE && bOne == false)
			{
				bOne = true;
				return true;
			}
			
			if(p.z == FLPoint.TWO && bTwo == false){
				bTwo = true;
				return true;
			}
			return false;
		}
	}
}